package irio.pythcal;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnMultiChoiceClickListener;
import android.text.InputType;
import android.view.Gravity;
import android.widget.EditText;
import android.widget.TextView;

public class DialogFactory {

	Context context;
	PaintView pView;
	public EditText edtScale;
	
	public DialogFactory(Context context, PaintView pView) {
		this.context = context;
		this.pView = pView;
	}
	
	public AlertDialog buildScaleDialog() {
		AlertDialog.Builder builder = new AlertDialog.Builder(context);
		edtScale = new EditText(context);
		edtScale.setInputType(InputType.TYPE_CLASS_NUMBER);
		builder.setView(edtScale);
		builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int whichButton) {
				pView.setVisualScale(edtScale.getText().toString().trim());
				
			}
		});
		AlertDialog scaleDialog = builder.create();
		pView.scaleDialog = scaleDialog;
		pView.edtScale = edtScale;
		return scaleDialog;
	}

	public AlertDialog buildAboutDialog(String aboutText) {
		AlertDialog.Builder builder = new AlertDialog.Builder(context);
		TextView txtAbout = new TextView(context);
		txtAbout.setText(aboutText);
		txtAbout.setTextSize(14);
		txtAbout.setGravity(Gravity.CENTER);
		builder.setView(txtAbout);
		builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int whichButton) {
				
			}
		});
		return builder.create();
	}

	public AlertDialog buildSettingsDialog() {
		
		AlertDialog.Builder builder = new AlertDialog.Builder(context);
		builder.setTitle("Settings");
		builder.setMultiChoiceItems(PythCal.cont.settingsText, PythCal.cont.settings, new OnMultiChoiceClickListener() {
			
			public void onClick(DialogInterface dialog, int which, boolean isChecked) {
				
			}
		});
		builder.setPositiveButton( "OK", new OnClickListener() {
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
			}
		}
		
		);
		
		return builder.create();
	}
}
